<?php $this->placeholder('container-class')->set('post_ad boat')?>
<?php $this->JQuery()->javascriptCaptureStart()?>
jQuery(function() {
    $('#saleby-Dealer').click(function() {
        $('#agentname_label').show();
        $('#agentphone_label').show();
        $('#agentmail_label').show();
        $('#id_input_agent').show();

        $('#ownername_label').hide();
        $('#ownerphone_label').hide();
        $('#ownermail_label').hide();
    });

    $('#saleby-Owner').click(function() {
        $('#agentname_label').hide();
        $('#agentphone_label').hide();
        $('#agentmail_label').hide();
        $('#id_input_agent').hide();

        $('#ownername_label').show();
        $('#ownerphone_label').show();
        $('#ownermail_label').show();
    });

    $('#add_more_btn').click(function() {
        if ($('#add_more_checkbox').attr('value') == 1) {
            $('#add_more_checkbox').attr('value',0);
        }
        else {
            $('#add_more_checkbox').attr('value',1);
        }
        $('#add_more').toggle();
        return false;
    });

    if ($('#add_more_checkbox').attr('value') == 0) {
        $('#add_more').show();
    }
    else {
        $('#add_more').hide();
    }

    // Control for Title
    $('input#tl_en').keydown(function(event) {
        var charLength = 100 - $(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span#counter_title').html('<em>'+charLength + '</em> <?php echo $this->t('characters remaining')?>');
        }
    });

    // Control for Description
    $('textarea#cs_en').keydown(function(event) {
        var charLength = 3000 - $(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span#counter_description').html('<em>'+charLength + '</em> <?php echo $this->t('characters remaining')?>');
        }
    });

    //Online Only Area
    if ($j("#area_l1").val() == "4cbe455a8835c17c10060000") {
        $j("#district_div").hide();
    }
    else {
        $j("#district_div").show();
    }

    $j('#preview_link').click(function() {
        var action = $j('#listing_form').attr('action');
        $j('#listing_form').attr('action', '<?php echo $this->preview_link?>');
        $j('#listing_form').attr('target','_blank');
        $j('#listing_form').submit();
        $j('#listing_form').attr('action', action);
        $j('#listing_form').attr('target','_self');
        return false;
    });
});
<?php $this->JQuery()->javascriptCaptureEnd()?>
<?php $this->placeholder('big-section-class')->set('boat') ?>

<form action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod())?>" id="listing_form"  enctype="multipart/form-data">
    <fieldset>
		<legend><?php echo $this->t('Create Your Ad');?></legend>
		<div class="desc2">
			<?php if( $this->current_language == 'tc'): ?>
			<p><?php echo $this->t('If you want to publish ads in English, please <a href="'.$this->url_en.'">click here</a> to fill out.');?></p>
			<?php else: ?>
			<p><?php echo $this->t('如果你想刊登中文廣告, 請<a href="'.$this->url_tc.'">按此</a>填寫.');?></p>
			<?php endif; ?>
		</div>
          <div class="required"><?php echo $this->t('Required Information');?></div>
            <div class="category desc2">
              <label><?php echo $this->t('Selected Categories')?>
                  <?php /*if (!isset($_GET['id'])):?>
                    (<a href="<?php echo $this->geturl('post-an-ad', 'listing', null, null, array('category' => $_GET['category'], 'change' => 1))?>">Change</a>)
                  <?php endif;*/?>
                  :</label>
              <ul>
                  <?php foreach($this->category as $cat):?>
                      <li>
                          <?php
                            $tmp = array();
                            foreach($cat->getParentTree() as $p) {
                                $tmp[] = $p->name;
                            }
                            echo implode(' &gt; ', $tmp);
                          ?>
                      </li>
                  <?php endforeach;?>
             </ul>
            </div>
            <input type="hidden" name="adid" id="adid" value="<?php echo $this->adid?>">
            <?php foreach($this->category as $cat):?>
                <input type="hidden" name="category[]" value="<?php echo $cat->_id?>">
            <?php endforeach;?>

            <div class="title text">
              <label class="required"><?php echo $this->t('Title')?></label>
              <span id="counter_title"><?php echo $this->t('<em>100</em> characters remaining')?></span>
              <?php echo $this->form->tl_en ?>
              <?php if (!empty($_POST['tl_en'])) { ?>
              <?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['tl_en'])) { ?>
                  <ul class="errors"><li><?php echo $this->t('Please remove email')?></li></ul>
              <?php } } ?>
            </div>

            <div class="custom_info">
                <div class="custom_info_1">
                    
                    <div class="nopreviousowners select">
                        <label class="required"><?php echo $this->t('Number of Previous Owners')?></label>
                        <?php echo $this->form->previousowners ?>
                    </div>
                    <div class="feature select">
                        <label class="required"><?php echo $this->t('boat-form-feature')?></label>
                        <?php echo $this->form->feature ?>
                    </div>
                    <div class="area select">
                        <label class="required"><?php echo $this->t('Area')?></label>
                        <?php echo $this->form->area_l1 ?>
                    </div>
                    <div class="district select" id="district_div">
                      <label class="required"><?php echo $this->t('District')?></label>
                        <?php echo $this->form->district ?>
                    </div>
                    <div class="address textarea">
                        <label><?php echo $this->t('Building Name, Street Address')?></label>
                        <?php echo $this->form->st_en ?>
                    </div>
                </div>
                <div class="custom_info_2">
                    <div class="boattype select">
                        <label class="required"><?php echo $this->t('Boat Type')?></label>
                        <?php echo $this->form->boattype ?>
                    </div>
                    <div class="model select">
                        <label class="required"><?php echo $this->t('Boat Category')?></label>
                        <?php echo $this->form->boatcategory ?>
                    </div>
                    <div class="cartype text">
                        <label class="required"><?php echo $this->t('Make')?></label>
                        <?php echo $this->form->make ?>
                    </div>
                    <div class="sale_price price text">
                        <span class="required"><?php echo $this->t('Price (Numbers only)')?></span>
                        <label><?php echo $this->t('HKD')?></label>
                        <label><?php echo $this->form->saleprice ?></label>
                    </div>
                    <div class="yearmanufactured select">
                        <label class="required"><?php echo $this->t('Year Manufactured')?></label>
                        <?php echo $this->form->yearmanufactured ?>
                    </div>
                    <div class="yearmanufactured select">
                        <label class="required"><?php echo $this->t('Length')?></label>
                        <?php echo $this->form->length ?>
                    </div>
                </div>
            </div>
                
            <div class="property_info_optional">
                <div class="description textarea">
                  <label class="required"><?php echo $this->t('Description')?></label>
                  <span id="counter_description"><?php echo $this->t('<em>3000</em> characters remaining')?></span>
                  <?php echo $this->form->cs_en?>
                  <?php if (!empty($_POST['cs_en'])) { ?>
                  <?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['cs_en'])) { ?>
                      <ul class="errors"><li><?php echo $this->t('Please remove email')?></li></ul>
                  <?php } } ?>
                  <span id="info_description"><?php echo $this->t('To prevent spam, do not enter any email addresses.')?></span>
                </div>                
            </div>

            <div class="property_info_more button desc2" id="add_more_btn">
                <?php echo $this->form->add_more_checkbox?>
                <button id="add_more_btn"><?php echo $this->t('Add More')?></button>
                <p><?php echo $this->t('Click to "Add More" specifications to your Boat Info')?></p>
            </div>

            <div class="property_info_more optional" id="add_more" style="display:none;">
                <h1><?php echo $this->t('Key Features')?></h1>
                    <div class="1 radio">
                        <span><?php echo $this->t('Engine Type')?></span>
                        <?php echo $this->form->enginetype;?>                        
                    </div>
                    <div class="2 radio">
                        <span><?php echo $this->t('Fuel Capacity')?></span>
                        <?php echo $this->form->fuelcapacity;?>
                    </div>
                    <div class="3 radio">
                        <span><?php echo $this->t('Hull Material')?></span>
                        <?php echo $this->form->hullmaterial;?>                                      
                    </div>
                    <div class="options select">
                        <label><?php echo $this->t('Model Year')?></label>
                        <?php echo $this->form->modelyear;?>
                    </div>
                    <div class="select">
                        <label><?php echo $this->t('Fuel Type')?></label>
                        <?php echo $this->form->fueltype;?>
                    </div>
                    <div class="select">
                        <label><?php echo $this->t('Trailer Included')?></label>
                        <?php echo $this->form->trailerincluded;?>   
                    </div>
                           
            </div>
                
            <?php echo $this->Partial('/index/photo-uploader.phtml', 'listing', array('listing' => $this->listing));?>
			<div class="desc2">
				<p><?php echo $this->t('To reach more people, your Ad will be automatically translated and posted in both English and Chinese.');?></p>
			</div>
            <p class="button_em">
				<button type="submit" name="postyourad"><?php echo $this->t('Post Your Ad')?></button>
			</p>
            <p class="preview button">
           <button id="review-your-ad" type="submit" name="review"><?php echo $this->t('Edit Translation')?></button>
			</p>
          </fieldset>
        </form>
